Procedure
Create Stored Procedure
The Create Stored Procedure feature enables you to create and manage stored procedures with the help of AI. You can define the procedure name, parameters, return type, and automatically generate the procedure code.
Interface Overview
The Create Procedure screen consists of the following elements:
- Name:
- A text input field where you can enter the name of the stored procedure.
- Example:
getUserData
.
Code Editor
The center of the screen features a code editor where you can manually write or edit the stored procedure. This editor allows you to define the logic of your procedure in SQL or any other supported query language.
- Code Editor Features:
- Syntax highlighting for SQL.
- Dark theme for enhanced focus.
- Example: Define the procedure body here.
Example Chart Visualizations
Here are some example visualizations created using Digisquares:
AI-Generated Procedure Code
The Generate Stored Procedure Code with AI section enables you to automatically generate the stored procedure code based on the provided information.
-
Message Field:
- A field where you can add a message or description to guide the AI in generating the stored procedure.
- Example: "Generate a stored procedure to fetch user details based on
user_id
."
-
Send Button:
- Click the button to send your request to the AI, which will generate the appropriate stored procedure code based on your description.
Actions Available
- Send: Generates the procedure code automatically based on the provided message.
Params and Return Type
To the right of the editor, there are two buttons for configuring the procedure:
-
Params:
- Use this button to add parameters for the stored procedure (e.g., input/output parameters).
-
Return Type:
- Define the return type of the stored procedure.
Defining Parameters
The Params section allows you to define the input parameters for your stored procedure. These parameters pass values to the procedure when it is executed.
Parameters Interface
-
Name:
- Specify the name of the parameter. For example, the parameter is named
parameter1
.
- Specify the name of the parameter. For example, the parameter is named
-
Type:
- Define the type of the parameter. This could be
string
,int
,float
, etc., depending on the data type required. - In this example, the type is
string
.
- Define the type of the parameter. This could be
-
Value (Optional):
- Assign a default value to the parameter, if needed.
-
Add/Delete Parameter:
- Use the + button to add another parameter.
- Use the trash icon to delete the selected parameter.
Actions Available
- Save: Save the parameters you've defined.
- Cancel: Close the window without saving changes.
Defining Return Type
The Return Type section allows you to define the type of value that the stored procedure will return.
Return Type Interface
-
Name:
- Specify the name for the return type. In the example provided, it’s named
procedure1
.
- Specify the name for the return type. In the example provided, it’s named
-
Type:
- Choose the return type, such as
string
,int
,float
, etc., depending on what the procedure will return. - In this example, the return type is
string
.
- Choose the return type, such as
-
Value (Optional):
- Assign a default value for the return type, if necessary.
-
Add/Delete Return Type:
- Use the + button to add another return type.
- Use the trash icon to delete the selected return type.
Actions Available
- Save: Save the return type you've defined.
- Cancel: Close the window without saving changes.
Sample Generated Code
Here’s an example of a stored procedure code that could be generated:
CREATE PROCEDURE getUserData (IN user_id INT)
BEGIN
-- Fetch user details based on user_id
SELECT id, username, email, created_at
FROM users
WHERE id = user_id;
END;